<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>获取不带任何参数或片段标识符的当前路径</title>
    <style>
        .link {
            text-decoration: none;
            color:#535455;
            margin-bottom: 10px;
            transition: color .4s cubic-bezier(0.165, 0.84, 0.44, 1);
        }
        .link:hover {
            color:#2396ef;
        }
        .content {
            line-height: 1.5;
            color:#446677;
        }
    </style>
</head>
<body>
    <a href="#/?html=getBaseURL&css=getBaseURL" id="link" class="link">clicked me</a>
    <div id="content" class="content"></div>
    <script>
       const getBaseURL = url => url.replace(/[?#].*$/,'');
       const link = document.querySelector("#link");
       link.addEventListener("click",e => {
            e.preventDefault();
            document.querySelector("#content").innerHTML = getBaseURL(window.location.href);
       })
    </script>
</body>
</html>